package com.yunji.cabinet.context.validate;

import com.yunji.common.enums.business.CapacityOperateEnum;
import com.yunji.common.enums.common.ErrorEnum;
import com.yunji.common.utils.DecimalUtils;
import org.springframework.util.Assert;

import java.math.BigDecimal;

public class CapacityValidate {

    public static void checkHeight(BigDecimal typeHeight, BigDecimal productHeight) {
        Assert.isTrue(DecimalUtils.more(typeHeight,BigDecimal.ZERO), ErrorEnum.CHECKED_711002.getText());
        Assert.isTrue(DecimalUtils.more(productHeight,BigDecimal.ZERO), ErrorEnum.CHECKED_711002.getText());
        Assert.isTrue(!DecimalUtils.less(typeHeight,productHeight), ErrorEnum.CHECKED_711002.getText());
    }

    public static boolean checkQuantity(Integer ordinalQuantity, Integer presentQuantity,Integer capacityCode) {
         if (CapacityOperateEnum.SUBTRACT.getCode().equals(capacityCode)){
             if (ordinalQuantity >= presentQuantity){
                 return true;
             }
         }
         return false;
    }

}
